package com.hiabr.iep.admin.controller;

import com.hiabr.iep.admin.api.CommonService;
import com.hiabr.iep.admin.vo.req.UploadTypeReqVo;
import com.hiabr.iep.common.domain.vo.resp.BaseResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 通用 前端控制器
 * </p>
 *
 * @author jie huang
 * @since 2023-06-28
 */
@RestController
public class CommonController {

    @Resource
    private CommonService commonService;

    @PostMapping("/file/upload")
    public BaseResponse<?> fileUpload(@RequestParam("file") MultipartFile file, @Valid UploadTypeReqVo req) {
        String url = commonService.upload(file, req);
        return BaseResponse.ok(url);
    }
}
